<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <div class="layui-input-inline">
            <input type="hidden" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span style="color: #bd3004">温馨提示*：</span></label>
            <div class="layui-input-inline" style="padding: 9px 0px;" >
                <span>该爬虫是爬取<a href="https://www.zol.com.cn/" style="color: #bd3004">中关村</a>数据。</span>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">爬取页数</label>
            <div class="layui-input-inline" style="display:flex;align-items:center">
                <input type="number" id="start" name="start" value="0" autocomplete="off"
                       class="layui-input"> ~
                <input type="number" id="end" name="end" value="9999" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submit">确认</button>
            <button class="layui-btn layui-btn-primary" onclick="cenCel()">取消</button>
        </div>
    </div>
</div>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script>
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var tree = layui.tree;
    var curIfr = parent.layer.getFrameIndex(window.name);
    //监听提交
    form.on('submit(submit)', function (data) {
        data.field.start = Number(data.field.start)
        data.field.end = Number(data.field.end)
        if(data.field.start >data.field.end){
            layer.msg("结束值小于开始值，请正确填写！")
            return  false;
        }else if(data.field.start<0){
            layer.msg("开始值要大于等于0，请正确填写！")
            return  false;
        }else if(data.field.end<0){
            layer.msg("结束值要大于等于0，请正确填写！")
            return  false;
        }


        CoreUtil.sendPost("/jokes/riddle", data.field, function (res) {});
        layer.msg("请求已发送，请耐心等等，稍后请刷新页面（请求时间与爬取页数有关）！！！！");
        return false;
    });

    function cenCel() {
        parent.layer.close(curIfr);
    }

</script>
</body>
</html>